import React  from 'react'
import Header from '../../components/Header/Header'
import Cate from './components/Cate/Cate'
import Banner from './components/Banner/Banner'
import New from "./components/New/New"
import Groupon from "./components/Groupon/Groupon"
import Seckill from "./components/Seckill/Seckill"
import { reqgetbanner, reqgetindexgoods, reqgetnew,reqgetgroupon, reqgetseckill,  } from '../../http/api'
 class fn  extends React.Component {
     constructor(){
         super()
         this.state={
             goods:[],
             banner:[],
             newgoods:[],
             groupongoods:[],
             countgoods:[],
             seckill:[],
             n:0
         }
     }
     componentDidMount(){
        reqgetindexgoods().then(res=>{
            this.setState({
                goods:res.data.list
            })
         })
         reqgetbanner().then(res=>{
             this.setState({
                 banner:res.data.list
             })
         })
         reqgetnew().then(res=>{
             this.setState({
                newgoods:res.data.list
                
             })            
         })
         reqgetgroupon().then(res=>{
             this.setState({
                groupongoods:res.data.list 
             })
         })
         reqgetseckill().then(res=>{
             this.setState({
                seckill:res.data.list
             })
         })        
     }
  render() {
      let{goods,banner,newgoods,groupongoods,seckill,n} = this.state
    return (
      <div>
          <Header title="首页"></Header>
          {/* 新人专享 */}
          <New newgoods={newgoods}></New>
          {/* 轮播 */}
          <Banner banner={banner}></Banner>
          {/* 分类 */}
          <Cate goods={goods} n={n} onChangeN={n=>{
              this.setState({
                  n
              })
          }} ></Cate>
          {/* 万人团 */}
          <Groupon groupongoods ={groupongoods}></Groupon>
          {/* 秒杀活动 */}
          <Seckill seckill={seckill}></Seckill>
      </div>
    )
  }
}
export default fn
